<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简易在线投票系统</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <nav class="navbar navbar-dark bg-primary">
        <div class="container">
            <span class="navbar-brand mb-0 h1">
                <i class="fas fa-vote-yea"></i> 简易在线投票系统
            </span>
        </div>
    </nav>

    <div class="container mt-5">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header">
                        <h4 class="mb-0">创建新投票</h4>
                    </div>
                    <div class="card-body">
                        <form id="createPollForm">
                            <div class="mb-3">
                                <label for="pollTitle" class="form-label">投票标题</label>
                                <input type="text" class="form-control" id="pollTitle" placeholder="请输入投票标题" required>
                            </div>
                            
                            <div class="mb-3">
                                <label class="form-label">投票选项</label>
                                <div id="optionsContainer">
                                    <div class="input-group mb-2">
                                        <input type="text" class="form-control option-input" placeholder="选项1" required>
                                        <button class="btn btn-outline-danger" type="button" onclick="removeOption(this)">
                                            <i class="fas fa-times"></i>
                                        </button>
                                    </div>
                                    <div class="input-group mb-2">
                                        <input type="text" class="form-control option-input" placeholder="选项2" required>
                                        <button class="btn btn-outline-danger" type="button" onclick="removeOption(this)">
                                            <i class="fas fa-times"></i>
                                        </button>
                                    </div>
                                </div>
                                <button type="button" class="btn btn-outline-primary" onclick="addOption()">
                                    <i class="fas fa-plus"></i> 添加选项
                                </button>
                            </div>

                            <div class="mb-3">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="multipleChoice">
                                    <label class="form-check-label" for="multipleChoice">
                                        允许多选
                                    </label>
                                </div>
                            </div>

                            <button type="submit" class="btn btn-primary w-100">
                                <i class="fas fa-plus-circle"></i> 创建投票
                            </button>
                        </form>
                    </div>
                </div>

                <div id="resultCard" class="card mt-4" style="display: none;">
                    <div class="card-header">
                        <h5 class="mb-0">投票创建成功</h5>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label class="form-label">投票链接</label>
                            <div class="input-group">
                                <input type="text" class="form-control" id="pollLink" readonly>
                                <button class="btn btn-outline-secondary" type="button" onclick="copyLink()">
                                    <i class="fas fa-copy"></i> 复制
                                </button>
                            </div>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">二维码</label>
                            <div class="text-center">
                                <img id="qrCode" class="img-fluid" style="max-width: 200px;">
                            </div>
                        </div>
                        <div class="d-grid gap-2">
                            <a id="viewPollBtn" class="btn btn-success" href="#">
                                <i class="fas fa-eye"></i> 查看投票
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js"></script>
    <script src="{{ url_for('static', filename='js/index.js') }}"></script>
</body>
</html>
